﻿namespace Harness.Commands
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using SHDocVw;

    internal class SetActiveBrowserCommand : ICommand
    {
        #region Constants

        private const int InternetExplorerArgIndex = 0;

        #endregion

        #region Public Methods

        public void SyntaxCheck(IHarness harness, IEnumerable<object> args)
        {
            if (null == args.ElementAtOrDefault(InternetExplorerArgIndex))
            {
                throw new ArgumentNullException((InternetExplorerArgIndex + 1).ToString() + ":InternetExplorer");
            }
        }

        public dynamic Execute(IHarness harness, IEnumerable<object> args)
        {
            InternetExplorer ie = args.ElementAtOrDefault(InternetExplorerArgIndex) as InternetExplorer;

            IE.ActiveBrowser = ie;

            return null;
        }
        
        #endregion
    }
}
